﻿using BankSystemWithCSharp.DataBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BankSystemWithCSharp
{
    public class GetMoneyController : IGetMoney
    {
        public void GetMoney(string money)
        {
            if (money.Length == 0)
            {
                MessageBox.Show("请输入取款金额");
                return;
            }
            if (!money.All(char.IsDigit))
            {
                MessageBox.Show("只能输入无符号整数");
                return;
            }
            double moneyNumber = double.Parse(money);
            if (moneyNumber % 100 != 0)
            {
                   MessageBox.Show("只能输入100的倍数");
                return;
            }
            try
            {
                BankDataBase.Intance.WithdrawMoney(moneyNumber);
                MessageBox.Show("取款成功");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}